<?php
/* SVN FILE: $Id: statistics_player.php 250 2010-06-17 10:55:41Z gregory.rome $ */
/**
 * Model.
 *
 * @todo Add file description.
 *
 * cBBweb : Digital Blood Bowl league interface (http://code.google.com/p/cbbweb/)
 * Copyright 2009-2010, Grégory Romé.
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @copyright     Copyright 2009-2010, Grégory Romé.
 * @link          http://code.google.com/p/cbbweb/ cBBweb Project
 * @package       cbbweb
 * @subpackage    cbbweb.models
 * @version       $Revision: 250 $
 * @modifiedby    $LastChangedBy: gregory.rome $
 * @lastmodified  $Date: 2010-06-17 10:55:41 +0000 (Thu, 17 Jun 2010) $
 * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
 */

/**
 * Model.
 *
 * CREATE TABLE Statistics_Players (
 *   ID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
 *   idPlayer_Listing INTEGER ,
 *   iMatchPlayed INTEGER ,
 *   iMVP INTEGER ,
 *   Inflicted_iPasses INTEGER ,
 *   Inflicted_iCatches INTEGER ,
 *   Inflicted_iInterceptions INTEGER ,
 *   Inflicted_iTouchdowns INTEGER ,
 *   Inflicted_iCasualties INTEGER ,
 *   Inflicted_iTackles INTEGER ,
 *   Inflicted_iKO INTEGER ,
 *   Inflicted_iStuns INTEGER ,
 *   Inflicted_iInjuries INTEGER ,
 *   Inflicted_iDead INTEGER ,
 *   Inflicted_iMetersRunning INTEGER ,
 *   Inflicted_iMetersPassing INTEGER ,
 *   Sustained_iInterceptions INTEGER ,
 *   Sustained_iCasualties INTEGER ,
 *   Sustained_iTackles INTEGER ,
 *   Sustained_iKO INTEGER ,
 *   Sustained_iStuns INTEGER ,
 *   Sustained_iInjuries INTEGER ,
 *   Sustained_iDead INTEGER )
 *
 * @todo Add model description.
 *
 * @package       cbbweb
 * @subpackage    cbbweb.models
 */
class StatisticsPlayer extends AppModel {

	var $name = 'StatisticsPlayer';
	var $primaryKey = 'ID';

	var $belongsTo = array(
		'Player' => array(
			'className' => 'Player',
			'foreignKey' => 'idPlayer_Listing',
			'fields' => array('Player.ID, Player.strName, Player.iNumber'),
		)
	);

	function afterFind($results, $primary=false) {
		if($primary == true) {
			if(Set::check($results, '0.0')) {
				foreach($results as $id => $result) {
					foreach ( $result[0] as $key => $value ) {
	       		$results[$id][$this->alias][$key] = $value;
					}
					unset($results[$id][0]);
				}

			}
	  }
		return $results;
	}

}
?>